import "./style/reset.css";
import Vue from "vue";
import App from "./App";
import routes from "./router";
import Vuex from "vuex";
import VueRouter from "vue-router";
import $ from "jquery";
window.$ = $;
import Config from "./config/index";
import Sto from "store";
// element
import {
    Steps,
    Step,
    Icon,
    Message,
    Loading
} from "element-ui";
Vue.use(Steps);
Vue.use(Step);
Vue.use(Icon);
Vue.component(Message);

Vue.use(Loading.directive);

Vue.prototype.$loading = Loading.service;
// vux
// import {
//     LoadingPlugin,
// } from "vux";

Vue.use(VueRouter);
Vue.use(Vuex);
// plugins
// Vue.use(LoadingPlugin);

Vue.prototype.$message = Message;
Vue.prototype.$sto = Sto;
Vue.prototype.$conf = Config;
Vue.config.productionTip = false;

// store为实例化生成的
var store = new Vuex.Store({
    //状态模型
    state: {
        bool: true,
        url: "https://stoy.98zhengxin.com",
        data: "",
        source: {},
        avatar: ""
    },
    //获取state的方法

    getters: {
        getData: function (state) {
            return state.data;
        },
        getSource: function (state) {
            return state.source;
        }
    },
    mutations: {
        setData: function (state, data) {
            state.data = data;
        },
        setSource: function (state, data) {
            state.source = data;
        }
    }
});

// 创建路由实例
const router = new VueRouter({
    routes: routes,
    mode: "hash",
    strict: process.env.NODE_ENV === "development", // 生产环境使用严格模式
    // 跳转页面到页面top
    scrollBehavior(to, from, savedPosition) {
        return {
            x: 0,
            y: 0
        };
    }
});

router.afterEach(transition => {});
new Vue({
    el: "#app",
    router,
    store,
    components: {
        App
    },
    template: "<App/>"
});
